package com.zhangyan.controller;

import java.io.IOException;

import com.zhangyan.common.BaseResponse;
import com.zhangyan.common.ErrorCode;
import com.zhangyan.service.ImageService;
import com.zhangyan.utils.GithubUploader;
import com.zhangyan.utils.ResultUtils;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload")
@CrossOrigin(origins = {"http://127.0.0.1:3000","http://192.168.34.154:3000/","http://119.3.166.98:8081/","http://172.31.10.13:8081/"}, allowCredentials = "true")
public class UploadController {


    @Resource
    private ImageService imageService;

    @PostMapping("/image")
    public BaseResponse<String> upload(@RequestParam("file") MultipartFile multipartFile) {

        return ResultUtils.success(imageService.uploadImage(multipartFile));
    }
}